package com.example.springiocdi.Controller;


import com.example.springiocdi.Service.UserService;
import com.example.springiocdi.config.UserConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class HelloController {

//    //属性注入
//    @Autowired
//    private UserService userService;



    //构造方法注入
    private UserService userService;

    private UserConfig config;


//    public HelloController() {
//    }
//
//    public HelloController(UserService userService) {
//        this.userService = userService;
//    }
//
//    public HelloController(UserConfig config) {
//        this.config = config;
//    }
//
//
//    //指定默认构造方法注入
//    @Autowired
//    public HelloController(UserService userService, UserConfig config) {
//        this.userService = userService;
//        this.config = config;
//    }


    //set方法注入

@Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
@Autowired
    public void setConfig(UserConfig config) {
        this.config = config;
    }

    public void print(){
        System.out.println("hello controller");
        userService.print();
        config.print();
    }

}
